<?php
declare(strict_types=1);

namespace App\Service;

use App\Constants\XZXResponseCode;
use App\Model\Dao\TradeOrderBaseDao;
use App\Utils\CustomUtils;
use App\Utils\DateUtils;
use Hyperf\Di\Annotation\Inject;

class TradeOrderBaseService
{
    /**
     * @Inject()
     * @var TradeOrderBaseDao
     */
    private $TradeOrderBaseDao;

    public function list(array $param)
    {

        $limit = $param['limit'];
        $page = $param['page'];        

        $total = $this->TradeOrderBaseDao->getCount($param);
        $list = $this->TradeOrderBaseDao->getList($param, $page, $limit);

        foreach ($list as $k => $v) {
            (isset($v['createTime']) && !empty($v['createTime'])) && $v['createTime'] = DateUtils::getDateTime($v['createTime']);
            $list[$k] = $v;
        }

        $data = array(
            'total' => $total,
            'list' => $list
        );

        return CustomUtils::xeServiceReturnData(XZXResponseCode::SUCCESS_CODE,XZXResponseCode::getMessage(XZXResponseCode::SUCCESS_CODE),$data);
    }    
}